package com.sm.honkon.data.dao

import androidx.lifecycle.LiveData
import androidx.room.*
import com.sm.honkon.data.bean.CustomerEntity

/**
 * @description
 * @author csw
 * @date 2021-05-05
 */
@Dao
interface CustomerDao {
    @Insert
    suspend fun insert(user: CustomerEntity)

    @Update
    suspend fun update(user: CustomerEntity)

    @Delete
    suspend fun delete(user: CustomerEntity)

    @Query("Delete FROM customers")
    suspend fun deleteAll()

    @Query("SELECT * FROM customers")
    fun getCustomers(): LiveData<List<CustomerEntity>>

    @Query("SELECT * FROM customers WHERE uid = :userId")
    fun getCustomer(userId: Long): LiveData<CustomerEntity>
}